package com.leinao.util.sha;
import java.math.BigInteger;
import java.security.MessageDigest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 
 * SHA加密处理
 * 
 * @author wangshoufa
 * @date 2018年6月21日 下午3:45:52
 */
public class SHAUtil {
   public static final String KEY_SHA = "SHA";
   private static final Logger logger = LoggerFactory.getLogger(SHAUtil.class);
  
   public static String getResult(String password){
    BigInteger sha =null;
    logger.info("=======加密前的数据:"+password.length());
    byte[] inputData = password.getBytes(); 
    try {
       MessageDigest messageDigest = MessageDigest.getInstance(KEY_SHA); 
       messageDigest.update(inputData);
       sha = new BigInteger(messageDigest.digest()); 
       logger.info("SHA加密后:" + sha.toString().length()); 
    } catch (Exception e) {e.printStackTrace();}
    return sha.toString();
  }
}
